package com.solution.admin.product.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.solution.admin.product.dao.ProductImageDao;
import com.solution.admin.product.entity.ProductImageEntity;
import com.solution.admin.product.service.ProductImageService;
import com.solution.common.dao.BaseDao;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.common.service.impl.BaseServiceImpl;

/**
 * 商品图片信息service实现层
 * @author xu_cc
 * @date 2017-08-31 20:42:43
 */
@Service
public class ProductImageServiceImpl extends BaseServiceImpl<ProductImageEntity> implements ProductImageService {

	/**
	 * 商品图片信息接口
	 */
	@Autowired
	private ProductImageDao productImageDao;

	protected BaseDao<ProductImageEntity> getDao() {
		return this.productImageDao;
	}

	/**
	 * 保存商品图片信息
	 * @param productImageEntity 商品图片信息实体
	 * @return Long 添加成功商品图片信息的ID
	 * @author xu_cc
	 * @date 2017-08-31 20:42:43
	 */
	public long saveProductImage(ProductImageEntity productImageEntity) {
		return productImageDao.saveProductImage(productImageEntity);
	}

    /**
     * 删除商品图片信息角色
     * 
     * @param id
     * @return
     * @author xu_cc
     * @date 2017-08-31 20:42:43
     */
    public int deleteByProductId(Long productId, String imageType) {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("productId", productId);
        param.put("imageType", imageType);
        return productImageDao.deleteByProductId(param);
    }

    /**
     * 根据商品图片信息类型获取商品图片信息
     * 
     * @param param
     * @return
     * @author xu_cc
     * @date 2017-08-31 20:42:43
     */
    public List<ProductImageEntity> listProductImage(Long productId, String imageType) {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("productId", productId);
        param.put("imageType", imageType);
        return productImageDao.listProductImage(param);
    }
    
    /**
     * 查询商品图片
     * @param parseLong
     * @return
     */
	public List<ProductImageEntity> listProductImageForProductDetail(long productId){
		Map<String, Object> param = new HashMap<String, Object>();
        param.put("productId", productId);
		return productImageDao.listProductImage(param);
	}
	
}
